Skip to main content

Register User

Methods for user registration and connecting the crypto wallet.

handleUserDetailsSubmit​

  • handleUserDetailsSubmit is the method used to register users with parameters such as the user's name, email address, and location.

  • ​returns the data which is the user's details, error returns error messages in case of error, submitUserDetails is the method which can be used to submit the data form after the data has been filled in.isLoading gives information about the loading status of the request.

handleOtpSubmit method​

  • handleOtpSubmit is the method used to submit OTP to verify the email address, it takes parameters like OTP and user's email.

  • ​Returns status the status of the request which is either successful or failed, data is the response data of the request, error is the error message in case of an error, isLoading informs about the loading status of the request, submitOtp is the method used to submit the OTP request on click of button.

handleResendOtp method​

  • The handleResendOtp method is used to resend the OTP request if the user does not receive the OTP email or the OTP time has expired, so that the user can request a new OTP code.

It takes email as a parameter.

Register User
export const ShowRegisterUser = () => {
const { registerUser } = MetastaqInstance;

const {
handleUserDetailsSubmit,
handleOtpSubmit,
handleResendOtp,
apiErrors,
} = registerUser();

const {
data: userData,
error: userError,
submitUserDetails,
} = handleUserDetailsSubmit({
name,
email,
location,
});

const { status, data, error, isFetching, isLoading, submitOtp } =
handleOtpSubmit(otp, email);

const { status, data, error, isFetching, isLoading, submitResendOtp } =
handleResendOtp(email);

const errorMessage = error[0]?.msg;

return (
<div>
<button onClick={submitUserDetails}>register user</button>
<button onClick={submitOtp}> verify otp</button>
<button onClick={submitResendOtp}> Resend otp</button>
<h1>
{isLoading
? "Loading..."
: errorMessage
? errorMessage
: "User Registered successfully."}
</h1>
</div>
);
};